package main

import (
	"fmt"
//	"math"
)

func main() {
   var mp1 = make(map[string]string)
   fmt.Println(mp1)
   
   var mp2 = map[string]string{}
   mp2["url"] = "qq.com"
   fmt.Println(mp2)
  
  // 判断key是否存在
   var userinfo = map[string]string{
      "username": "lisi",
	   "passwd": "221212",
   }
   
   v, ok := userinfo["username"]
   if ok {
     fmt.Println(v)
   }   else  {
    fmt.Println("novalue")
   }
   
   fmt.Println(userinfo)
   // 删除键值对
   delete(userinfo,"passwd")
   fmt.Println(userinfo)
   
   //map 遍历
   var sourceMap = map[string]int {
     "jason": 17,
	  "smith": 18,
	  "lily": 19,
   }
   //遍历所有
   for key, value := range sourceMap{
     fmt.Println(key,value)
   }
   //只遍历值
   for _, value := range sourceMap{
     fmt.Println(value)
   }
   //只遍历key
   for key := range sourceMap{
     fmt.Println(key)
   }
}